<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script>
			function getD(){
				let d1=document.getElementById("d1");
				d1.align="right";
				d1.innerHTML+="<a href='https://www.jd.com' target='_blank'>淘宝</a>";
				//d1.innerText+="<a href='https://www.jd.com' target='_blank'>淘宝</a>";
			}
			function getDiv(){
				let dr=document.getElementsByTagName("div");
				for(let d of dr){ 
					d.align=d.align=="right"?"left":"right";
				} 
			}
			function getLike(){
				let li=document.getElementsByName("like");
				console.dir(li);
				
				var choose="";
				for(let i in li){
					if(li[i].checked)
					  choose+=li[i].value+" ";
				}
				// for(let o of li){
				// 	if(o.checked)
				// 	  choose+=o.value+" ";
				// }
				document.getElementById("yourlike").innerHTML=choose;
			}
		</script>
	</head>
	<body>
		<div id="d1" >
			你好
		</div>
		<div id="d1" >
			Good morning
		</div>
		<div>
			大扎好，你是渣渣会
		</div>
		<p>
			<p>
				爱好:
				<input type="checkbox" name="like" value="dancing"/>跳舞
				<input type="checkbox" name="like" value="sing"/>唱歌
				<input type="checkbox" name="like" value="rap"/>说唱
				<input type="checkbox" name="like" value="baseketball"/>篮球
			</p>
			<p>
				你喜欢<span id="yourlike"></span>
			</p>
		</p>
		<p>
			<input type="button" value="获得d1元素" onclick="getD()" />
		<input type="button" value="获得div元素" onclick="getDiv()" />
		
		<input type="button" value="获得你的爱好" onclick="getLike()" />
		</p>
	</body>
</html>